const http = require("http");
const fs = require("fs");

const server = http.createServer();

server.on("request", (res) => {
  //解决跨域问题
  res.setHeader("Access-Control-Allow-Origin", "*");
  res.writeHead(200, {
    "content-type": "text/plain;charset=utf-8",
  });
    fs.readFile('data/product.json', (err, data) => {
        res.end(data)
    })
});

server.listen(3000, () => {
    console.log("http://127.0.0.1:3000");
});
